<template>
  <div>
    <div>
      <van-cell
        v-for="cnl in channels"
        :key="cnl.id"
        :title="cnl.name"
        :icon="cnl.image"
        :to="{ path: chatPath, query: { id: cnl.id } }"
        is-link
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'Message',
  components: {},
  directives: {},
  filters: {},

  props: {},

  data() {
    return {
      chatPath: '/mail/chat2'
      // chatPath: '/mail/chat',
    }
  },
  computed: {
    isEmployee: function() {
      return this.$store.state.user.isEmployee
    },

    channels: function() {
      return this.$store.state.MailChannel.dataList
    }
  },

  async created() {
    this.$store.dispatch('MailChannel/search_me')
    console.log('channels ', this.channels)
  },

  methods: {
    async onClick(item) {
      console.log('xxx, click item,', item)
    },

    async find_regiter({ doctor_id, customer_id }) {
      //
      // const SO = odoo.env('sale.order')
      // const domain = {
      //   partner_id: customer_id,
      //   'user_id.partner_id': doctor_id
      // }
      // const so = await SO.search({ domain })
      // console.log('xxx,so register,', so)
    },

    async surveyInput(item) {
      // const Survey = odoo.env('survey.survey')
      // const surveys = await Survey.search({
      //   fields: {
      //     question_ids: {
      //       title: null,
      //       question_type: null,
      //       labels_ids: { display_name: null }
      //     }
      //   }
      // })
      // console.log('survey,', surveys)
      // const survey_id = surveys[0].id
      // const User_input = odoo.env('survey.user_input')
      // // const user_input = await User_input.create({
      // //   survey_id,
      // //   partner_id: this.currentRow.me_partner_id
      // // })
      // // console.log('user_input,', user_input)
      // const user_inputs = await User_input.search()
      // console.log('user_input,', user_inputs)
      // const question_id = surveys[0].question_ids[0]
      // const question = surveys[0].question_ids__objects[0]
      // const user_input_id = user_inputs[1].id
      // const User_input_line = odoo.env('survey.user_input_line')
      // const user_input_line_vals = {
      //   user_input_id,
      //   question_id: question_id,
      //   answer_type: 'suggestion',
      //   value_suggested: question.labels_ids[1]
      // }
      // console.log('user_input_line_vals,', user_input_line_vals)
      // const user_input_line = await User_input_line.create(user_input_line_vals)
      // console.log('user_input,', user_input_line)
      // const user_input_line2 = await User_input_line.search()
      // console.log('user_input,', user_input_line2)
    },

    async consultConsultation(item) {
      // const Ptn = odoo.env('res.partner')
      // const doctor = await Ptn.browse_one(this.currentRow.partner_id, {
      //   fields: {
      //     consult_survey_ids: {
      //       display_name: null
      //     }
      //   }
      // })
      // console.log('doctor,', doctor)
      // const consult_survey = doctor.consult_survey_ids__objects[0]
      // console.log('consult_survey,', consult_survey)
      // const consult_survey_id = consult_survey.id
      // const Consultation = odoo.env('consult.consultation')
      // const User_input = odoo.env('survey.user_input')
      // const user_inputs = await User_input.search()
      // console.log('user_input,', user_inputs)
      // const user_input_id = user_inputs[1].id
      // const consultation = await Consultation.create({
      //   consult_survey_id,
      //   partner_id: this.currentRow.me_partner_id,
      //   response_id: user_input_id
      // })
      // console.log('consultation,', consultation)
      // const consultation2 = await Consultation.search()
      // console.log('consultation,', consultation2)
    }
  }
}
</script>

<style type="text/css"></style>
